package com.ecable.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ecable.bean.ConnectionTO;
import com.ecable.bean.ProfileTO;
import com.ecable.daoImpl.ConnectionDaoImpl;
import com.ecable.daoImpl.ProfileDAO;
import com.ecable.util.UtilConstants;

public class ViewConnectionStatusAction extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

               
		String path="";
		String userid=request.getParameter("userid");
			
		System.out.println("userid"+userid);
		Vector<ConnectionTO> vconn=null;
		
		try{
			vconn=new ConnectionDaoImpl().getConnectionStatus(userid);
			
			
			if(!vconn.isEmpty()){
				
				request.setAttribute("status", UtilConstants._Connection_INFO);
				request.setAttribute("userid", userid);
				request.setAttribute("vconn", vconn);
				
				path=UtilConstants._VIEW__Connection;
		
			}
			else
			{
				request.setAttribute("userid", userid);
				request.setAttribute("status", UtilConstants._NO__Connection);
				path=UtilConstants._VIEW__Connection;
				
			}
			
		}
		catch (Exception e) {
			
			request.setAttribute("status", UtilConstants._INVALIED_ENTRY);
			path=UtilConstants._VIEW__Connection;
			
		}
		RequestDispatcher rd=request.getRequestDispatcher(path);
		
		rd.forward(request, response);
		
   }

}
